<?php


/**
 * Base class that represents a query for the 'category' table.
 *
 * 
 *
 * @method     CategoryQuery orderByCatname($order = Criteria::ASC) Order by the catname column
 * @method     CategoryQuery orderByUpgrade($order = Criteria::ASC) Order by the upgrade column
 * @method     CategoryQuery orderByDescription($order = Criteria::ASC) Order by the description column
 * @method     CategoryQuery orderByPrice($order = Criteria::ASC) Order by the price column
 * @method     CategoryQuery orderByMinage($order = Criteria::ASC) Order by the minage column
 *
 * @method     CategoryQuery groupByCatname() Group by the catname column
 * @method     CategoryQuery groupByUpgrade() Group by the upgrade column
 * @method     CategoryQuery groupByDescription() Group by the description column
 * @method     CategoryQuery groupByPrice() Group by the price column
 * @method     CategoryQuery groupByMinage() Group by the minage column
 *
 * @method     CategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method     CategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method     CategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method     CategoryQuery leftJoinCategoryRelatedByUpgrade($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryRelatedByUpgrade relation
 * @method     CategoryQuery rightJoinCategoryRelatedByUpgrade($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryRelatedByUpgrade relation
 * @method     CategoryQuery innerJoinCategoryRelatedByUpgrade($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryRelatedByUpgrade relation
 *
 * @method     CategoryQuery leftJoinCategoryRelatedByCatname($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryRelatedByCatname relation
 * @method     CategoryQuery rightJoinCategoryRelatedByCatname($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryRelatedByCatname relation
 * @method     CategoryQuery innerJoinCategoryRelatedByCatname($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryRelatedByCatname relation
 *
 * @method     CategoryQuery leftJoinModel($relationAlias = null) Adds a LEFT JOIN clause to the query using the Model relation
 * @method     CategoryQuery rightJoinModel($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Model relation
 * @method     CategoryQuery innerJoinModel($relationAlias = null) Adds a INNER JOIN clause to the query using the Model relation
 *
 * @method     CategoryQuery leftJoinOffers($relationAlias = null) Adds a LEFT JOIN clause to the query using the Offers relation
 * @method     CategoryQuery rightJoinOffers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Offers relation
 * @method     CategoryQuery innerJoinOffers($relationAlias = null) Adds a INNER JOIN clause to the query using the Offers relation
 *
 * @method     CategoryQuery leftJoinReservation($relationAlias = null) Adds a LEFT JOIN clause to the query using the Reservation relation
 * @method     CategoryQuery rightJoinReservation($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Reservation relation
 * @method     CategoryQuery innerJoinReservation($relationAlias = null) Adds a INNER JOIN clause to the query using the Reservation relation
 *
 * @method     Category findOne(PropelPDO $con = null) Return the first Category matching the query
 * @method     Category findOneOrCreate(PropelPDO $con = null) Return the first Category matching the query, or a new Category object populated from the query conditions when no match is found
 *
 * @method     Category findOneByCatname(string $catname) Return the first Category filtered by the catname column
 * @method     Category findOneByUpgrade(string $upgrade) Return the first Category filtered by the upgrade column
 * @method     Category findOneByDescription(string $description) Return the first Category filtered by the description column
 * @method     Category findOneByPrice(int $price) Return the first Category filtered by the price column
 * @method     Category findOneByMinage(int $minage) Return the first Category filtered by the minage column
 *
 * @method     array findByCatname(string $catname) Return Category objects filtered by the catname column
 * @method     array findByUpgrade(string $upgrade) Return Category objects filtered by the upgrade column
 * @method     array findByDescription(string $description) Return Category objects filtered by the description column
 * @method     array findByPrice(int $price) Return Category objects filtered by the price column
 * @method     array findByMinage(int $minage) Return Category objects filtered by the minage column
 *
 * @package    propel.generator.ise-php.om
 */
abstract class BaseCategoryQuery extends ModelCriteria
{
	
	/**
	 * Initializes internal state of BaseCategoryQuery object.
	 *
	 * @param     string $dbName The dabase name
	 * @param     string $modelName The phpName of a model, e.g. 'Book'
	 * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
	 */
	public function __construct($dbName = 'ise-php', $modelName = 'Category', $modelAlias = null)
	{
		parent::__construct($dbName, $modelName, $modelAlias);
	}

	/**
	 * Returns a new CategoryQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    CategoryQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof CategoryQuery) {
			return $criteria;
		}
		$query = new CategoryQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}

	/**
	 * Find object by primary key.
	 * Propel uses the instance pool to skip the database if the object exists.
	 * Go fast if the query is untouched.
	 *
	 * <code>
	 * $obj  = $c->findPk(12, $con);
	 * </code>
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    Category|array|mixed the result, formatted by the current formatter
	 */
	public function findPk($key, $con = null)
	{
		if ($key === null) {
			return null;
		}
		if ((null !== ($obj = CategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
			// the object is alredy in the instance pool
			return $obj;
		}
		if ($con === null) {
			$con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}
		$this->basePreSelect($con);
		if ($this->formatter || $this->modelAlias || $this->with || $this->select
		 || $this->selectColumns || $this->asColumns || $this->selectModifiers
		 || $this->map || $this->having || $this->joins) {
			return $this->findPkComplex($key, $con);
		} else {
			return $this->findPkSimple($key, $con);
		}
	}

	/**
	 * Find object by primary key using raw SQL to go fast.
	 * Bypass doSelect() and the object formatter by using generated code.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Category A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT `CATNAME`, `UPGRADE`, `DESCRIPTION`, `PRICE`, `MINAGE` FROM `category` WHERE `CATNAME` = :p0';
		try {
			$stmt = $con->prepare($sql);			
			$stmt->bindValue(':p0', $key, PDO::PARAM_STR);
			$stmt->execute();
		} catch (Exception $e) {
			Propel::log($e->getMessage(), Propel::LOG_ERR);
			throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
		}
		$obj = null;
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$obj = new Category();
			$obj->hydrate($row);
			CategoryPeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}

	/**
	 * Find object by primary key.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Category|array|mixed the result, formatted by the current formatter
	 */
	protected function findPkComplex($key, $con)
	{
		// As the query uses a PK condition, no limit(1) is necessary.
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		$stmt = $criteria
			->filterByPrimaryKey($key)
			->doSelect($con);
		return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
	}

	/**
	 * Find objects by primary key
	 * <code>
	 * $objs = $c->findPks(array(12, 56, 832), $con);
	 * </code>
	 * @param     array $keys Primary keys to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
	 */
	public function findPks($keys, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
		}
		$this->basePreSelect($con);
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		$stmt = $criteria
			->filterByPrimaryKeys($keys)
			->doSelect($con);
		return $criteria->getFormatter()->init($criteria)->format($stmt);
	}

	/**
	 * Filter the query by primary key
	 *
	 * @param     mixed $key Primary key to use for the query
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKey($key)
	{
		return $this->addUsingAlias(CategoryPeer::CATNAME, $key, Criteria::EQUAL);
	}

	/**
	 * Filter the query by a list of primary keys
	 *
	 * @param     array $keys The list of primary key to use for the query
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKeys($keys)
	{
		return $this->addUsingAlias(CategoryPeer::CATNAME, $keys, Criteria::IN);
	}

	/**
	 * Filter the query on the catname column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByCatname('fooValue');   // WHERE catname = 'fooValue'
	 * $query->filterByCatname('%fooValue%'); // WHERE catname LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $catname The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByCatname($catname = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($catname)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $catname)) {
				$catname = str_replace('*', '%', $catname);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(CategoryPeer::CATNAME, $catname, $comparison);
	}

	/**
	 * Filter the query on the upgrade column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByUpgrade('fooValue');   // WHERE upgrade = 'fooValue'
	 * $query->filterByUpgrade('%fooValue%'); // WHERE upgrade LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $upgrade The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByUpgrade($upgrade = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($upgrade)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $upgrade)) {
				$upgrade = str_replace('*', '%', $upgrade);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(CategoryPeer::UPGRADE, $upgrade, $comparison);
	}

	/**
	 * Filter the query on the description column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue'
	 * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $description The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByDescription($description = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($description)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $description)) {
				$description = str_replace('*', '%', $description);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(CategoryPeer::DESCRIPTION, $description, $comparison);
	}

	/**
	 * Filter the query on the price column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByPrice(1234); // WHERE price = 1234
	 * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
	 * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
	 * </code>
	 *
	 * @param     mixed $price The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByPrice($price = null, $comparison = null)
	{
		if (is_array($price)) {
			$useMinMax = false;
			if (isset($price['min'])) {
				$this->addUsingAlias(CategoryPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($price['max'])) {
				$this->addUsingAlias(CategoryPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(CategoryPeer::PRICE, $price, $comparison);
	}

	/**
	 * Filter the query on the minage column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByMinage(1234); // WHERE minage = 1234
	 * $query->filterByMinage(array(12, 34)); // WHERE minage IN (12, 34)
	 * $query->filterByMinage(array('min' => 12)); // WHERE minage > 12
	 * </code>
	 *
	 * @param     mixed $minage The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByMinage($minage = null, $comparison = null)
	{
		if (is_array($minage)) {
			$useMinMax = false;
			if (isset($minage['min'])) {
				$this->addUsingAlias(CategoryPeer::MINAGE, $minage['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($minage['max'])) {
				$this->addUsingAlias(CategoryPeer::MINAGE, $minage['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(CategoryPeer::MINAGE, $minage, $comparison);
	}

	/**
	 * Filter the query by a related Category object
	 *
	 * @param     Category|PropelCollection $category The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByCategoryRelatedByUpgrade($category, $comparison = null)
	{
		if ($category instanceof Category) {
			return $this
				->addUsingAlias(CategoryPeer::UPGRADE, $category->getCatname(), $comparison);
		} elseif ($category instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(CategoryPeer::UPGRADE, $category->toKeyValue('PrimaryKey', 'Catname'), $comparison);
		} else {
			throw new PropelException('filterByCategoryRelatedByUpgrade() only accepts arguments of type Category or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the CategoryRelatedByUpgrade relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function joinCategoryRelatedByUpgrade($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('CategoryRelatedByUpgrade');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'CategoryRelatedByUpgrade');
		}

		return $this;
	}

	/**
	 * Use the CategoryRelatedByUpgrade relation Category object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery A secondary query class using the current class as primary query
	 */
	public function useCategoryRelatedByUpgradeQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		return $this
			->joinCategoryRelatedByUpgrade($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'CategoryRelatedByUpgrade', 'CategoryQuery');
	}

	/**
	 * Filter the query by a related Category object
	 *
	 * @param     Category $category  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByCategoryRelatedByCatname($category, $comparison = null)
	{
		if ($category instanceof Category) {
			return $this
				->addUsingAlias(CategoryPeer::CATNAME, $category->getUpgrade(), $comparison);
		} elseif ($category instanceof PropelCollection) {
			return $this
				->useCategoryRelatedByCatnameQuery()
				->filterByPrimaryKeys($category->getPrimaryKeys())
				->endUse();
		} else {
			throw new PropelException('filterByCategoryRelatedByCatname() only accepts arguments of type Category or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the CategoryRelatedByCatname relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function joinCategoryRelatedByCatname($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('CategoryRelatedByCatname');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'CategoryRelatedByCatname');
		}

		return $this;
	}

	/**
	 * Use the CategoryRelatedByCatname relation Category object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery A secondary query class using the current class as primary query
	 */
	public function useCategoryRelatedByCatnameQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
	{
		return $this
			->joinCategoryRelatedByCatname($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'CategoryRelatedByCatname', 'CategoryQuery');
	}

	/**
	 * Filter the query by a related Model object
	 *
	 * @param     Model $model  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByModel($model, $comparison = null)
	{
		if ($model instanceof Model) {
			return $this
				->addUsingAlias(CategoryPeer::CATNAME, $model->getCatname(), $comparison);
		} elseif ($model instanceof PropelCollection) {
			return $this
				->useModelQuery()
				->filterByPrimaryKeys($model->getPrimaryKeys())
				->endUse();
		} else {
			throw new PropelException('filterByModel() only accepts arguments of type Model or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Model relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function joinModel($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Model');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Model');
		}

		return $this;
	}

	/**
	 * Use the Model relation Model object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ModelQuery A secondary query class using the current class as primary query
	 */
	public function useModelQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinModel($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Model', 'ModelQuery');
	}

	/**
	 * Filter the query by a related Offers object
	 *
	 * @param     Offers $offers  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByOffers($offers, $comparison = null)
	{
		if ($offers instanceof Offers) {
			return $this
				->addUsingAlias(CategoryPeer::CATNAME, $offers->getCatname(), $comparison);
		} elseif ($offers instanceof PropelCollection) {
			return $this
				->useOffersQuery()
				->filterByPrimaryKeys($offers->getPrimaryKeys())
				->endUse();
		} else {
			throw new PropelException('filterByOffers() only accepts arguments of type Offers or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Offers relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function joinOffers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Offers');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Offers');
		}

		return $this;
	}

	/**
	 * Use the Offers relation Offers object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    OffersQuery A secondary query class using the current class as primary query
	 */
	public function useOffersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinOffers($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Offers', 'OffersQuery');
	}

	/**
	 * Filter the query by a related Reservation object
	 *
	 * @param     Reservation $reservation  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function filterByReservation($reservation, $comparison = null)
	{
		if ($reservation instanceof Reservation) {
			return $this
				->addUsingAlias(CategoryPeer::CATNAME, $reservation->getCatname(), $comparison);
		} elseif ($reservation instanceof PropelCollection) {
			return $this
				->useReservationQuery()
				->filterByPrimaryKeys($reservation->getPrimaryKeys())
				->endUse();
		} else {
			throw new PropelException('filterByReservation() only accepts arguments of type Reservation or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Reservation relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function joinReservation($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Reservation');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Reservation');
		}

		return $this;
	}

	/**
	 * Use the Reservation relation Reservation object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ReservationQuery A secondary query class using the current class as primary query
	 */
	public function useReservationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinReservation($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Reservation', 'ReservationQuery');
	}

	/**
	 * Exclude object from result
	 *
	 * @param     Category $category Object to remove from the list of results
	 *
	 * @return    CategoryQuery The current query, for fluid interface
	 */
	public function prune($category = null)
	{
		if ($category) {
			$this->addUsingAlias(CategoryPeer::CATNAME, $category->getCatname(), Criteria::NOT_EQUAL);
		}

		return $this;
	}

} // BaseCategoryQuery